home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1997 August / Walnut Creek CDROM.7z / VOL_400 / 415_02 / CPP_LIBS / INCLUDE / IMPLSPEC.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-09  |  2.6 KB  |  83 lines

  1. #ifndef     _H_IMPL_SPEC
  2. #define     _H_IMPL_SPEC
  3.  
  4. #ifndef    lint
  5. static const char impl_spec_sccsid[]="%W% %G% %U%:Component-%Y% %Q%";
  6. #endif   //  lint
  7. #include     <limits.h>
  8.  
  9. const    int   IMPL_TABLE_INCR = 10 ;
  10. const    int   MAX_UID =  SHRT_MAX ;
  11.  
  12. // The following type definitions are declared global, instead of nested
  13. // because, the order (and number ) of calls that are made to static
  14. // constructors and destructors by Cfront generated code is sometimes
  15. // incorrect. Hence, depend upon a globally initialized variable.
  16. typedef    struct  impl_map_entry_s
  17.     {
  18.        int    uid ;
  19.        const char   *name ;
  20.     } impl_map_entry_t ;
  21.  
  22. typedef   struct impl_map_s
  23.     {
  24.       int  index ;
  25.       int  size ;
  26.       impl_map_entry_t    *entries ;
  27.     }  impl_map_t  ;
  28.  
  29. // The implsepec class manages the globally common data structures that are
  30. // used to maintain the class uid information. These structures normally
  31. // would be made static.
  32. class   ImplSpec : public  virtual CLASS
  33.   {
  34.    public :
  35.      ImplSpec()  ;
  36.      ImplSpec(const char *)  ;
  37.      virtual ~ImplSpec() ;
  38.      virtual  int operator == (ImplSpec & ) { return -1 ; } ;
  39.      virtual  int operator == (ImplSpec * ) { return -1;  } ;
  40.      virtual  int operator == (int & ) { return -1;  } ;
  41.      virtual  int operator != (ImplSpec &) { return -1; }  ;
  42.      virtual  int operator != (ImplSpec *) { return -1 ;}  ;
  43.      virtual  int operator != (int &) { return -1 ;}  ;
  44.      virtual operator int () { return 0;  }  ;
  45.      int      getuid(int n) { return ((id << 16) + n) ; } ;
  46.      RTTI_SCAFFOLDING_DECL(ImplSpec)
  47.  
  48.      private :
  49.     // private meta-data
  50.     impl_map_t          *table ;
  51.     impl_map_entry_t    *alloc_entries(void ) ;
  52.     int                  id ;
  53.     void                 init_tab(void ) ;
  54.     impl_map_entry_t    *find_name(const char *) ;
  55.     impl_map_entry_t    *register_name(const char *) ;
  56.     int                  is_index_valid(void ) ;
  57.   } ;
  58.  
  59. // The following class actually provides the front-end interface
  60. // for managing implmentation information.
  61. class  BaseImplSpec : public ImplSpec
  62.  {
  63. public :
  64.      BaseImplSpec(int,const char * ) ;
  65.      ~BaseImplSpec() { } ;
  66.      virtual int operator== (ImplSpec  &) ;
  67.      virtual int operator== (ImplSpec  *) ;
  68.      virtual int operator== (int  &) ;
  69.      virtual int operator!= (ImplSpec &) ;
  70.      virtual int operator!= (ImplSpec *) ;
  71.      virtual int operator!= (int &)  ;
  72.      virtual ImplSpec &operator = (int ) ;
  73.      virtual ImplSpec &operator = (ImplSpec &) ;
  74.      virtual operator int () ;
  75.      RTTI_SCAFFOLDING_DECL(BaseImplSpec)
  76.    private :
  77.      int   type ;
  78.  } ; // a specification of the Base Implementation category
  79.  
  80.  
  81.  
  82. #endif   // _H_IMPL_SPEC
  83.